<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,inital-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="format-detection" content="telephone=no, email=no"/>
    <title>骡窝窝积分商城</title>
    <link href="/shop/css/reset.css" rel="stylesheet" type="text/css"/>
    <link href="/shop/css/css.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="/shop/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="/shop/css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="/shop/css/loaders.min.css"/>
    <link rel="stylesheet" type="text/css" href="/shop/css/loading.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/shop/js/base.js"></script>
    <script src="/shop/js/rem.js"></script>
    <script src="/shop/js/aui-car.js"></script>
    <script src="/js/plugins/form/jquery.form.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>
    <script>
        $(function () {
            var user = $.parseJSON(sessionStorage.getItem("user"));
            var params = getParams();
            //商品id
            //订单id

            jQuery.ajaxSettings.traditional = true;

            //商品
            var product;

            //回显商品信息
            $.get("/products/" + params.id, function (data) {
                product = data;
                $(".clearfix").renderValues(data);
            });


            $('#immediatePayment').click(function () {

                var success;
                //点击购买之后改变订单状态为3
                $.post("/orders/2", {id: params.oid, userId: user.id, 'product.id': params.id}, function (data) {
                    if (data.success) {
                        //进行支付后积分的减少
                        $.post("/scores", {ownScore: product.productPrice, 'user.id': user.id}, function (data) {
                            if (data.success) {
                                location.href = "/shop/pay-success.html";
                            }
                        });
                    } else {
                        $(document).dialog({
                            content: '支付异常'
                        });
                    }
                });


            })


        })
    </script>
</head>

<body>
<div class="wrap clearfix">
    <header class="mui-bar mui-bar-nav" id="header">
        <a class="" href="javascript:history.go(-1)">
            <i class="iconfont icon-fanhui"></i>
        </a>
        <h4>订单结算</h4>
    </header>
    <div class="clear"></div>
    <!-- header end -->
    <ul class="list-tab btline mt10 clearfix">
        <li class="item">
            <a class="order-addr tap pl-24 arrow" href="/mine/myAddress.html">
                <i class="icon-addr icon"></i>
                <span class="">地址:广东省广州市野鸡坨镇野鸡坨村</span>
                <i class="icon-arrow icon"></i>
            </a>
        </li>
    </ul>
    <ul class="plist2 clearfix" id="listProduct">
        <li class="clearfix">
            <a data-href="/mall/productDetail.html?id=" class="tap clearfix">
                <div class="imgbox box-sizing"><img render-src="productImg" class="lazy"/></div>
                <div class="text-box box-sizing">
                    <div class="name" render-html="productName"></div>
                    <div class="price-box">
                        <span class="red unit" render-html="productPrice"></span>积分
                        <span class="num">x<i>1</i></span>
                    </div>
                </div>
            </a>
        </li>

    </ul>

    <div class="title-bt">结算</div>
    <ul class="list-tab btline mt10 clearfix">
        <li class="item">
            <div class="tap">
                <span class="name">运费</span>
                <span class="dsp c5">免邮</span>
            </div>
        </li>
        <li class="item">
            <div class="tap">
                <span class="name">订单总额</span>
                <div class="transFee">
                    <span class="dsp" render-html="productPrice">积分</span>
                    <span class="dsp" id="dsp"></span>
                </div>
            </div>
        </li>
    </ul>

    <div class="title-bt"></div>
    <!-- footer begin -->
    <div class="clear"></div>
    <nav class="bot-nav jj">
        <div class="count-box totalMoney">共计 1 件，总额：
            <!--渲染金额-->
            <span class="red unit" render-html="productPrice"> <font class="unit" id="unit"></font>积分</span>
        </div>
        <a class="ljgm-btn pa paying" id="immediatePayment">立即支付</a>
    </nav>
</div>
</body>
</html>